package p270jp.pxv.android.activity;

import android.content.ComponentCallbacks;
import android.os.Bundle;
import androidx.appcompat.widget.Toolbar;
import androidx.compose.p026ui.platform.C0536v1;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.tabs.TabLayout;
import java.util.ArrayList;
import java.util.List;
import p014ae.AbstractActivityC0176w1;
import p018ai.PixivSettings;
import p047bg.C1124a;
import p064c6.Preconditions;
import p089d.C2419a;
import p109dj.ScrollableToTop;
import p134ei.AnalyticsScreenName;
import p189gn.AbstractC3435a;
import p210hh.PixivAccountManager;
import p216hn.Lambda;
import p216hn.Reflection;
import p270jp.pxv.android.R;
import p270jp.pxv.android.topLevel.presentation.TopLevelStore;
import p310lc.C4621b;
import p314lg.ActivityNewWorksBinding;
import p325m0.MutabilityOwnership;
import p370ni.StartUpScreen;
import p374nm.ToolbarMenuView;
import p436q6.C5768b;
import p547uh.MyPixivWorksFragment;
import p547uh.NewFollowWorksFragment;
import p547uh.NewestWorksFragment;
import p551ul.TopLevelStoreExtension;
import p579vo.Qualifier;
import p603wm.AbstractC6949c;
import p603wm.Tuples;
import p625xi.LegacyNavigation;

/* compiled from: NewWorksActivity.kt */
/* renamed from: jp.pxv.android.activity.NewWorksActivity */
/* loaded from: classes2.dex */
public final class NewWorksActivity extends AbstractActivityC0176w1 {

    /* renamed from: n0 */
    public static final /* synthetic */ int f18424n0;

    /* renamed from: j0 */
    public final AbstractC6949c f18425j0 = C4621b.m3851a(this, C4027b.f18431c);

    /* renamed from: k0 */
    public final AbstractC6949c f18426k0 = Preconditions.m9802P(1, new C4029d(this, null, null));

    /* renamed from: l0 */
    public final AbstractC6949c f18427l0 = Preconditions.m9802P(1, new C4030e(this, null, null));

    /* renamed from: m0 */
    public C4026a f18428m0;

    /* compiled from: NewWorksActivity.kt */
    /* renamed from: jp.pxv.android.activity.NewWorksActivity$a */
    /* loaded from: classes2.dex */
    public static final class C4026a extends FragmentPagerAdapter {

        /* renamed from: h */
        public final List<Fragment> f18429h;

        /* renamed from: i */
        public final List<String> f18430i;

        /* JADX WARN: Multi-variable type inference failed */
        public C4026a(FragmentManager fragmentManager, List<? extends Fragment> list, List<String> list2) {
            super(fragmentManager, 1);
            this.f18429h = list;
            this.f18430i = list2;
        }

        @Override // p094d4.PagerAdapter
        /* renamed from: c */
        public int mo938c() {
            return this.f18429h.size();
        }

        @Override // p094d4.PagerAdapter
        /* renamed from: e */
        public CharSequence mo4759e(int i) {
            return this.f18430i.get(i);
        }

        @Override // androidx.fragment.app.FragmentPagerAdapter
        /* renamed from: m */
        public Fragment mo4805m(int i) {
            return this.f18429h.get(i);
        }
    }

    /* compiled from: NewWorksActivity.kt */
    /* renamed from: jp.pxv.android.activity.NewWorksActivity$c */
    /* loaded from: classes2.dex */
    public static final class C4028c extends TabLayout.C2210j {
        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4028c(ViewPager viewPager) {
            super(viewPager);
            NewWorksActivity.this = r1;
        }

        @Override // com.google.android.material.tabs.TabLayout.C2210j, com.google.android.material.tabs.TabLayout.AbstractC2201c
        /* renamed from: a */
        public void mo4699a(TabLayout.C2207g gVar) {
            C4026a aVar = NewWorksActivity.this.f18428m0;
            if (aVar != null) {
                MutabilityOwnership.m3747j(gVar);
                Fragment fragment = aVar.f18429h.get(gVar.f9764d);
                if (fragment instanceof ScrollableToTop) {
                    ((ScrollableToTop) fragment).mo1600a();
                    return;
                }
                return;
            }
            MutabilityOwnership.m3737u("adapter");
            throw null;
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.NewWorksActivity$d */
    /* loaded from: classes2.dex */
    public static final class C4029d extends Lambda implements AbstractC3435a<PixivSettings> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18433a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4029d(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18433a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [ai.b, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final PixivSettings invoke() {
            return C1124a.m10173s(this.f18433a).f24118a.m920a().m621a(Reflection.m5499a(PixivSettings.class), null, null);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.NewWorksActivity$e */
    /* loaded from: classes2.dex */
    public static final class C4030e extends Lambda implements AbstractC3435a<LegacyNavigation> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18434a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4030e(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18434a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [java.lang.Object, xi.a] */
        @Override // p189gn.AbstractC3435a
        public final LegacyNavigation invoke() {
            return C1124a.m10173s(this.f18434a).f24118a.m920a().m621a(Reflection.m5499a(LegacyNavigation.class), null, null);
        }
    }

    public NewWorksActivity() {
        super(R.layout.activity_new_works);
    }

    /* renamed from: g1 */
    public final ActivityNewWorksBinding m4806g1() {
        return (ActivityNewWorksBinding) this.f18425j0.getValue();
    }

    @Override // p014ae.TopLevelActivity, p270jp.pxv.android.activity.AbstractActivityC4151b, p270jp.pxv.android.activity.BaseActivity, androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        MaterialToolbar materialToolbar = m4806g1().f21419d;
        MutabilityOwnership.m3746l(materialToolbar, "binding.toolBar");
        C0536v1.m11537h(this, materialToolbar, R.string.new_works);
        m11131K0().m11251d0("fragment_request_key_charcoal_dialog_fragment", this, new C5768b(this, 9));
        TopLevelStore f1 = m12131f1();
        FragmentManager K0 = m11131K0();
        MutabilityOwnership.m3746l(K0, "supportFragmentManager");
        TopLevelStoreExtension.m1380a(f1, this, K0, this, this, (LegacyNavigation) this.f18427l0.getValue());
        Toolbar.C0375e eVar = new Toolbar.C0375e(-2, -1);
        eVar.f12463a = 8388613;
        ToolbarMenuView q0Var = new ToolbarMenuView(this);
        q0Var.setSelectedItem(1);
        m4806g1().f21419d.addView(q0Var, eVar);
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        NewFollowWorksFragment a6Var = new NewFollowWorksFragment();
        Bundle bundle2 = new Bundle();
        bundle2.putSerializable("illust_manga_screen_name", AnalyticsScreenName.NEW_FROM_FOLLOWING_ILLUST_MANGA);
        bundle2.putSerializable("novel_screen_name", AnalyticsScreenName.NEW_FROM_FOLLOWING_NOVEL);
        a6Var.setArguments(bundle2);
        arrayList.add(a6Var);
        arrayList2.add(getString(R.string.new_works_follow));
        NewestWorksFragment.C6423a aVar = NewestWorksFragment.f27424E;
        NewestWorksFragment d6Var = new NewestWorksFragment();
        NewestWorksFragment.C6423a aVar2 = NewestWorksFragment.f27424E;
        d6Var.setArguments(C2419a.m7858f(new Tuples("illust_screen_name", AnalyticsScreenName.NEW_ALL_ILLUST), new Tuples("manga_screen_name", AnalyticsScreenName.NEW_ALL_MANGA), new Tuples("novel_screen_name", AnalyticsScreenName.NEW_ALL_NOVEL)));
        arrayList.add(d6Var);
        arrayList2.add(getString(R.string.new_works_newest));
        if (PixivAccountManager.m5511e().f16506l) {
            MyPixivWorksFragment x5Var = new MyPixivWorksFragment();
            Bundle bundle3 = new Bundle();
            bundle3.putSerializable("illust_manga_screen_name", AnalyticsScreenName.NEW_MY_PIXIV_ILLUST_MANGA);
            bundle3.putSerializable("novel_screen_name", AnalyticsScreenName.NEW_MY_PIXIV_NOVEL);
            x5Var.setArguments(bundle3);
            arrayList.add(x5Var);
            arrayList2.add(getString(R.string.new_works_mypixiv));
        }
        FragmentManager K02 = m11131K0();
        MutabilityOwnership.m3746l(K02, "supportFragmentManager");
        this.f18428m0 = new C4026a(K02, arrayList, arrayList2);
        ViewPager viewPager = m4806g1().f21420e;
        C4026a aVar3 = this.f18428m0;
        if (aVar3 != null) {
            viewPager.setAdapter(aVar3);
            m4806g1().f21418c.setupWithViewPager(m4806g1().f21420e);
            m4806g1().f21418c.setOnTabSelectedListener((TabLayout.AbstractC2202d) new C4028c(m4806g1().f21420e));
            ((PixivSettings) this.f18426k0.getValue()).m12120h(StartUpScreen.NEW_WORKS);
            m12132e1().m4555e();
            return;
        }
        MutabilityOwnership.m3737u("adapter");
        throw null;
    }
}
